using System;
using Microsoft.SPOT;

namespace Bt.WebServer
{
    public class HttpRequest
    {
        // GET /?Open=true HTTP/1.1
        // Accept: image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
        // Referer: http://192.168.0.15/
        // Accept-Language: cs,en-GB;q=0.7,en;q=0.3
        // Accept-Encoding: gzip, deflate
        // User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; InfoPath.2)
        // Host: 192.168.0.15
        // Connection: Keep-Alive

        public HttpRequest(string rawRequest)
        {
            int idx = 0;
            foreach (char ch in rawRequest) 
            {
                if (idx == 0) 
                {
                    if (ch == ' ') 
                    {
                        idx++; 
                        continue; 
                    }
                    this.Method += ch;
                }
                else if (idx == 1)
                {
                    if (ch == ' ')
                    {
                        idx++;
                        continue;
                    }
                    this.Url += ch;
                }
            }
        }
        public string Method { get; private set; }

        public string Url { get; private set; }
    }
}